{{!
  Copyright (c) HashiCorp, Inc.
  SPDX-License-Identifier: BUSL-1.1
~}}

<PageHeader as |p|>
  <p.top>
    <Hds::Breadcrumb>
      <Hds::Breadcrumb::Item @text="Auth Methods" @route="vault.cluster.access.methods" data-test-access-methods />
      <Hds::Breadcrumb::Item @text={{@methodModel.id}} @current={{true}} />
    </Hds::Breadcrumb>
  </p.top>
  <p.levelLeft>
    <h1 class="title is-3">
      {{@methodModel.id}}
    </h1>
  </p.levelLeft>
</PageHeader>
{{#let (tabs-for-auth-section @methodModel "authConfig" @paths) as |tabs|}}
  {{#if tabs.length}}
    <div class="tabs-container box is-sideless is-fullwidth is-paddingless is-marginless">
      <nav class="tabs">
        <ul>
          {{#each tabs as |tab|}}
            <li>
              <LinkTo @route={{get tab.routeParams 0}} @model={{get tab.routeParams 1}} data-test-auth-section-tab={{true}}>
                {{tab.label}}
              </LinkTo>
            </li>
          {{/each}}
        </ul>
      </nav>
    </div>
  {{/if}}
{{/let}}
<Toolbar>
  <ToolbarActions>
    <ToolbarLink
      @route="vault.cluster.access.method.item.create"
      @model={{this.itemType}}
      @type="add"
      data-test-entity-create-link={{this.itemType}}
    >
      Create
      {{singularize this.itemType}}
    </ToolbarLink>
  </ToolbarActions>
</Toolbar>
<ListView
  @items={{this.model}}
  @itemNoun={{this.itemType}}
  @paginationRouteName="vault.cluster.access.method.item.list"
  as |list|
>
  {{#if list.empty}}
    <list.empty
      @title="No {{pluralize this.itemType}} yet"
      @message="A list of {{pluralize
        this.itemType
      }} will be listed here. Create your first {{this.itemType}} to get started."
    >
      <LinkTo @route="vault.cluster.access.method.item.create" @model={{this.itemType}} class="link">
        Create
        {{singularize this.itemType}}
      </LinkTo>
    </list.empty>
  {{else if list.item}}
    <ListItem @linkParams={{array "vault.cluster.access.method.item.show" this.itemType list.item.id}} as |Item|>
      <Item.content>
        <Icon @name="folder" class="has-text-grey-light" />{{list.item.id}}
      </Item.content>
      <Item.menu>
        <li class="action">
          <LinkTo @route="vault.cluster.access.method.item.show" @model={{list.item.id}} class="is-block">
            View
            {{singularize this.itemType}}
          </LinkTo>
        </li>
        <li class="action">
          <LinkTo @route="vault.cluster.access.method.item.edit" @model={{list.item.id}} class="is-block">
            Edit
            {{singularize this.itemType}}
          </LinkTo>
        </li>
        <ConfirmAction
          @isInDropdown={{true}}
          @onConfirmAction={{action
            (perform
              Item.callMethod
              "destroyRecord"
              list.item
              (concat "Successfully deleted " (singularize this.itemType) " " list.item.id ".")
              (concat "There was an error deleting this " (singularize this.itemType))
              (action "refreshItemList")
            )
          }}
          @confirmTitle="Delete {{singularize this.itemType}}?"
          @confirmMessage="Are you sure you want to delete {{singularize this.itemType}} {{list.item.id}}?"
          @buttonText="Delete {{singularize this.itemType}}"
        />
      </Item.menu>
    </ListItem>
  {{/if}}
</ListView>